<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    *{
      margin: 0;
      padding: 0;
    }
    i,
    em{
      font-style: normal;
    }
    #window_open{
      display: block;
      position: absolute;
      top: 20%;
      left: 20%;
      width: 150px;
      height: 40px;
      background-color: #fff;
      border: 1px solid #333;
      border-radius: 5px;
    }

    .window_box{
      display: none;
      position: absolute;
      width: 100%;
      height: 100%;
      background-color: rgba(246, 246, 246, .7);
      z-index: 10000;
    }
    .window_box i{
      position: absolute;
      top: 5px;
      right: 7px;
      width: 20px;
      height: 20px;
      line-height: 20px;
      border-radius: 50%;
      background-color: red;
      cursor: pointer;
      text-align: center;
      font-size: 20px;
      color: #fff;
    }
    .box{
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%,-50%);
      width: 600px;
      height: 400px;
      border-radius: 10px;
      box-shadow: 2px 4px 6px 1px rgb(200, 200, 200);
      background-color: #fff;
      border: 1px solid darkgray;
      box-sizing: border-box;
      z-index: 10001;
    }
    .window_box .content{
      margin-top: 30px;
      width: 598px;
      height: 320px;
      border-top: 1px solid rgb(200, 200, 200);
      border-bottom: 1px solid rgb(200, 200, 200);
    }
    #secess_wd{
      display: none;
      position: absolute;
      top: 40%;
      left: 50%;
      transform: translate(-50%,-50%);
      margin: 40px 0 0 90px;
      width: 400px;
      height: 100px;
      line-height: 100px;
      background-color: #fff;
      border: 1px solid rgb(200, 200, 200);
      border-radius: 5px;
      box-shadow: 2px 4px 6px 1px rgb(200, 200, 200);
      font-size: 18px;
      text-align: center;

    }

    .window_btn{
      position: absolute;
      bottom: 5px;
      right: 10px;
      width: 180px;
      height: 30px;
      line-height: 30px;
    }
    .window_btn button{
      margin-right: 10px;
      width: 70px;
      height: 30px;
      line-height: 30px;
      border: none;
      font-size: 16px;
      color: #fff;
    }
    .window_btn .btn_cancel{
      background-color: skyblue;
    }
    .window_btn .btn_cancel:hover{
      background-color: rgb(135, 239, 239);
    }
    .window_btn .btn_confirm {
      background-color: rgb(255, 0, 0);
    }
    .window_btn .btn_confirm:hover{
      background-color: rgb(255, 100, 100);
    }



  </style>
</head>
<body>  
  <button id="window_open">弹窗按钮</button>
  <!-- 成功页面 -->
  <div id="secess_wd"></div>
  <!-- 弹窗 -->
  <div class="window_box" id="window_box">
    <div class="box">
      <!-- 右上角关闭按钮 -->
      <i id="close_window">×</i>
      
      <!-- 内容区域 -->
      <div class="content"></div>
      <!-- 按钮区域 -->
      <div class="window_btn">
        <button class="btn_confirm" id="confirm">确定</button>
        <button class="btn_cancel" id="cancel">取消</button>
      </div>
    </div>
  </div>




<script>
  var wd_box = document.getElementById('window_box');
  var wd_open =document.getElementById('window_open');
  var close_wd = document.getElementById('close_window');
  var confirm = document.getElementById('confirm');
  var seccuss = document.getElementById('secess_wd');



  // 点击弹窗按钮打开弹窗
  wd_open.onclick = function(){
    console.log('button被点击了');
    wd_box.style.display = 'block';
  }
  // 点击关闭按钮事件
  close_wd.onclick = function(){
    console.log('关闭按钮 被点击了');
    wd_box.style.display = 'none';
  }
  // 点击取消按钮事件
  cancel.onclick = function(){
    wd_box.style.display = 'none';
    console.log("取消按钮被点击了");
  }
  // 点击确认

  confirm.onclick = function(){
    wd_box.style.display = 'none';
    seccuss.style.display = 'block';
    setTimeout(() =>{
      seccuss.innerHTML = "请等待，正在提交";
    },3000)
    console.log("打开成功页面");
      // 打开成功页面
    // setInterval(timer(), 0.1s, );

    // function timer(){
    //     // 当前时间戳
    //     var date = new Date();  
    //     // 获取起始时间戳
    //     var now = date.valueOf();
    //     // 截止时间戳
    //     var deadline = now + 3000;
    //     var t = deadline - date;
    //     var time = t.toLocaleString()
    //     return time;
    //     console.log(time);
    // }

    // var startTime = 0;
    // setInterval(() => {
    //   var date = new Date();
    // },100)

    seccuss.innerHTML = "提交成功,3s后返回主页";
    setInterval(() => {

    },100)
    setTimeout(() => {
      // 关闭成功页面
      seccuss.style.display = 'none';
      console.log("关闭成功窗口");
    },3000)
  }

</script>
</body>
</html>